#version 130

precision highp float;

uniform float point_size;
uniform sampler2D texture;

in float vAlpha;
in vec4 color;
in vec4 Position;
in float Life;

out vec4 gl_FragColor;

const vec4 startColor = vec4( 0.99f, 0.94f, 0.70f, 1.0f );
//const vec4 endColor = vec4( 0.76f, 0.25f, 0.02f, 1.0f );
const vec4 endColor = vec4( 1.0f, 0.25f, 0.02f, 1.0f );

void main( void )
{
	//vec2 texCoord = vec2( 0.0f, 0.0f);

	//gl_FragColor = texture2D(texture, texCoord);
	//gl_FragColor.a = vAlpha * 0.5;

	vec2 v_rot = normalize( Position.zw );
	vec4 texCoord = vec4( 0.0, 0.0, gl_PointCoord.xy );
	texCoord.zw	-= vec2( 0.5, 0.5 );

	texCoord.x	= texCoord.z * v_rot.x;
	texCoord.y	= texCoord.w * v_rot.x;
	texCoord.x	-= texCoord.w * v_rot.y;
	texCoord.y	+= texCoord.z * v_rot.y;

	gl_FragColor = texture2D( texture, texCoord.xy + vec2( 0.5, 0.5 ) );
	gl_FragColor.a *= ( 1 - vAlpha ) * 0.5;
}
